import math

class Point:
    x = 0
    y = 0
    angle = 135
    velocity_x = 5
    velocity_y = -5
        
    def get_velocity(self):
        power = math.pow(self.velocity_x, 2) + math.pow(self.velocity_y, 2)
        return math.sqrt(power)
        
    def set_velocity(self, velocity ):
        self.velocity_x = velocity * math.cos( self.angle * math.pi / 180 ) 
        self.velocity_y = - velocity * math.sin( self.angle * math.pi / 180 )

    def rotate_left ( self ):
        self.angle = self.angle + 5

    def rotate_right ( self ):
        self.angle = self.angle - 5

    def speed_up ( self ):
        self.velocity_x = self.velocity_x + math.cos( self.angle * math.pi / 180 ) / 10
        self.velocity_y = self.velocity_y - math.sin( self.angle * math.pi / 180 ) / 10
        self.__limit_velocity__()
        
        
    def __limit_velocity__(self):
        if self.velocity_x > self.max_velocity :
            self.velocity_x = self.max_velocity ;
        if self.velocity_y > self.max_velocity :
            self.velocity_y = self.max_velocity ;
        if self.velocity_x < -self.max_velocity :
            self.velocity_x = -self.max_velocity ;
        if self.velocity_y < -self.max_velocity :
            self.velocity_y = -self.max_velocity ;
            

    def speed_down( self ):
        self.velocity_x = self.velocity_x - math.cos( self.angle * math.pi / 180 ) / 10
        self.velocity_y = self.velocity_y + math.sin( self.angle * math.pi / 180 ) / 10
        
        self.__limit_velocity__()

    def move( self ):
        self.x = self.x + self.velocity_x
        self.y = self.y + self.velocity_y
        if self.y > 400:
            self.y = -60
        if self.y < -60:
            self.y = 400
        if self.x > 800:
            self.x = -60
        if self.x < -60:
            self.x = 800
            
    def collide_y(self):
        self.velocity_y = - self.velocity_y
    
    def collide_x(self):
        self.velocity_x = - self.velocity_x
        
            
    def move_up(self, x_velocity):
        self.velocity_y = -abs(self.velocity_y)
        if x_velocity != None and x_velocity != 0:
            if x_velocity > 0:
                direction = 1
            if x_velocity < 0:
                direction = -1;
            x_velocity = abs(x_velocity)
            x_velocity = max(3, x_velocity)
            x_velocity = min(15, x_velocity)
            self.velocity_x = direction * x_velocity
            
    def collide_x(self):
        self.velocity_x = - self.velocity_x
        
    def is_in_screen( self ):
        return self.y < 400 and self.y > -60 and self.x < 800 and self.x > -60